var e = require;
var t = module;
var o = exports;
var Adv_skd=require("./Adv_skd");
Object.defineProperty(o, "__esModule", { value: !0 }),
    (o.SettleNavigate = o.NavigateSide = o.NavigateDirection = o.ResultEnum = void 0);
var n,
    a = e("AudioManager"),
    i = e("UIManager"),
    r = e("ASCAd"),
    s = e("sdkConfig"),
    l = e("MiniGameSDK"),
    c = e("ObjectTool"),
    d = e("Toast"),
    h = cc._decorator,
    _ = h.ccclass;
h.property,
    (function(e) {
        (e[(e.Success = 1)] = "Success"), (e[(e.Fail = 2)] = "Fail");
    })((n = o.ResultEnum || (o.ResultEnum = {}))),
    (function(e) {
        (e.Vertical = "vertical"), (e.Horizontal = "horizontal");
    })(o.NavigateDirection || (o.NavigateDirection = {})),
    (function(e) {
        (e.Left = "left"), (e.Right = "right");
    })(o.NavigateSide || (o.NavigateSide = {})),
    (function(e) {
        (e[(e.BigWindow = 1)] = "BigWindow"),
        (e[(e.BothSide = 2)] = "BothSide"),
        (e[(e.Bar = 3)] = "Bar"),
        (e[(e.Box = 4)] = "Box");
    })(o.SettleNavigate || (o.SettleNavigate = {}));
var u = (function() {
    function e() {
        (this.isBackground = !1),
        (this.IntervalTime = 0),
        (this.RefreshTime = 0),
        (this.isPause = !1),
        (this.DanceByteMoreGame = null);
    }
    var t;
    return (
        (t = e),
        (e.getInstance = function() {
            return t.instance || (t.instance = new t()), t.instance;
        }),
        Object.defineProperty(e.prototype, "interFlag", {
            get: function() {
                return (
                    (s.default.platform == s.EPlatform.test ||
                        s.default.platform == s.EPlatform.VIVO ||
                        s.default.platform == s.EPlatform.OPPO ||
                        s.default.platform == s.EPlatform.TikTok ||
                        s.default.platform == s.EPlatform.QQ ||
                        s.default.platform == s.EPlatform.HUAWEI ||
                        s.default.platform == s.EPlatform.WX ||
                        s.default.platform == s.EPlatform.UC ||
                        s.default.platform == s.EPlatform.M4399box ||
                        s.default.platform == s.EPlatform.M4399mini) &&
                    r.default.getInstance().getIntersFlag()
                );
            },
            enumerable: !1,
            configurable: !0
        }),
        Object.defineProperty(e.prototype, "videoFlag", {
            get: function() {
                return (
                    (s.default.platform == s.EPlatform.VIVO ||
                        s.default.platform == s.EPlatform.OPPO ||
                        s.default.platform == s.EPlatform.TikTok ||
                        s.default.platform == s.EPlatform.QQ ||
                        s.default.platform == s.EPlatform.HUAWEI ||
                        s.default.platform == s.EPlatform.WX ||
                        s.default.platform == s.EPlatform.UC ||
                        s.default.platform == s.EPlatform.M4399box ||
                        s.default.platform == s.EPlatform.M4399mini) &&
                    r.default.getInstance().getVideoFlag()
                );
            },
            enumerable: !1,
            configurable: !0
        }),
        Object.defineProperty(e.prototype, "NavigateIconFlag", {
            get: function() {
                return (
                    (s.default.platform == s.EPlatform.VIVO ||
                        s.default.platform == s.EPlatform.OPPO ||
                        s.default.platform == s.EPlatform.TikTok ||
                        s.default.platform == s.EPlatform.WX) &&
                    r.default.getInstance().getNavigateIconFlag()
                );
            },
            enumerable: !1,
            configurable: !0
        }),
        Object.defineProperty(e.prototype, "NavigateGroupFlag", {
            get: function() {
                return (
                    (s.default.platform == s.EPlatform.VIVO ||
                        s.default.platform == s.EPlatform.OPPO ||
                        s.default.platform == s.EPlatform.TikTok ||
                        s.default.platform == s.EPlatform.WX) &&
                    r.default.getInstance().getNavigateGroupFlag()
                );
            },
            enumerable: !1,
            configurable: !0
        }),
        Object.defineProperty(e.prototype, "NavigateSettleFlag", {
            get: function() {
                return (
                    (s.default.platform == s.EPlatform.VIVO ||
                        s.default.platform == s.EPlatform.OPPO ||
                        s.default.platform == s.EPlatform.TikTok ||
                        s.default.platform == s.EPlatform.WX) &&
                    r.default.getInstance().getNavigateSettleFlag()
                );
            },
            enumerable: !1,
            configurable: !0
        }),
        (e.prototype.init = function(e) {
            s.default.platform == s.EPlatform.test ||
                s.default.platform == s.EPlatform.VIVO ||
                s.default.platform == s.EPlatform.OPPO ||
                s.default.platform == s.EPlatform.QQ ||
                s.default.platform == s.EPlatform.HUAWEI ||
                s.default.platform == s.EPlatform.UC ||
                s.default.platform == s.EPlatform.M4399box ||
                s.default.platform == s.EPlatform.M4399mini ?
                (r.default.getInstance().initAd(),
                    e && e(),
                    this.NetworkSubscribe(),
                    this.AdLog("接入数据上报"),
                    l.default.onApplication(this.onApplication.bind(this))) :
                (s.default.platform == s.EPlatform.WX ||  s.default.platform == s.EPlatform.TikTok) ?
                e && e() :
                s.default.platform == s.EPlatform.No_AD && e && e();
        }),
        (e.prototype.NetworkSubscribe = function() {
            l.default.subscribeNetworkStatus(function(e) {
                e ||
                    l.default.showDialog("提示", "无网络，请退出游戏重启网络", function() {
                        l.default.exitApplication();
                    });
            });
        }),
        (e.prototype.onApplication = function(e) {
            if (e) {
                var t = this;
                this.AdLog("游戏进入前台"),
                    setTimeout(function() {
                        t.isBackground = !1;
                    }, 2e3);
            } else(this.isBackground = !0), this.AdLog("游戏进入后台");
        }),
        (e.prototype.setGroup = function(e) {
            (s.default.platform != s.EPlatform.test &&
                s.default.platform != s.EPlatform.VIVO &&
                s.default.platform != s.EPlatform.OPPO &&
                s.default.platform != s.EPlatform.TikTok &&
                s.default.platform != s.EPlatform.HUAWEI &&
                s.default.platform != s.EPlatform.UC &&
                s.default.platform != s.EPlatform.M4399box &&
                s.default.platform != s.EPlatform.M4399mini) ||
            r.default.getInstance().setGroup(e);
        }),
        (e.prototype.showBanner = function() {
            // s.default.platform == s.EPlatform.test ||
            // s.default.platform == s.EPlatform.VIVO ||
            // s.default.platform == s.EPlatform.OPPO ||
            // s.default.platform == s.EPlatform.TikTok ||
            // s.default.platform == s.EPlatform.QQ ||
            // s.default.platform == s.EPlatform.HUAWEI ||
            // s.default.platform == s.EPlatform.UC ||
            // s.default.platform == s.EPlatform.M4399box ||
            // s.default.platform == s.EPlatform.M4399mini
            //     ? r.default.getInstance().showBanner()
            //     : (s.default.platform, s.EPlatform.No_AD);
        }),
        (e.prototype.hideBanner = function() {
            // s.default.platform == s.EPlatform.test ||
            // s.default.platform == s.EPlatform.VIVO ||
            // s.default.platform == s.EPlatform.OPPO ||
            // s.default.platform == s.EPlatform.TikTok ||
            // s.default.platform == s.EPlatform.QQ ||
            // s.default.platform == s.EPlatform.HUAWEI ||
            // s.default.platform == s.EPlatform.UC ||
            // s.default.platform == s.EPlatform.M4399box ||
            // s.default.platform == s.EPlatform.M4399mini
            //     ? r.default.getInstance().hideBanner()
            //     : (s.default.platform, s.EPlatform.No_AD);
        }),
        (e.prototype.showInter = function() {
            // s.default.platform == s.EPlatform.test ||
            //     s.default.platform == s.EPlatform.VIVO ||
            //     s.default.platform == s.EPlatform.OPPO ||
            //     s.default.platform == s.EPlatform.TikTok ||
            //     s.default.platform == s.EPlatform.QQ ||
            //     s.default.platform == s.EPlatform.HUAWEI ||
            //     s.default.platform == s.EPlatform.UC ||
            //     s.default.platform == s.EPlatform.M4399box ||
            //     s.default.platform == s.EPlatform.M4399mini ?
            //     t.getInstance().interFlag && r.default.getInstance().showInters() :
            //     (s.default.platform, s.EPlatform.No_AD);
        }),
        (e.prototype.showVideo = function(e) {

            Adv_skd.default.instance.showVideo(()=>{
                e(n.Success)
            }, ()=>{
                e(n.Fail)
            })
            
        }),
        (e.prototype.gameTaskInfo = function() {
            cc.find("UIManager").getComponent(i.default).playerTaskOverInfo(10, 1);
        }),
        (e.prototype.showVideoBtn = function() {
            return s.default.platform != s.EPlatform.HUAWEI || r.default.getInstance().getVideoFlag();
        }),
        (e.prototype.showNavigateIcon = function(e, t, o, n) {
            (s.default.platform != s.EPlatform.VIVO &&
                s.default.platform != s.EPlatform.OPPO &&
                s.default.platform != s.EPlatform.TikTok &&
                s.default.platform != s.EPlatform.WX) ||
            r.default.getInstance().showNavigateIcon(e, t, o, n);
        }),
        (e.prototype.showNavigateGroup = function(e, t, o, n) {
            (s.default.platform != s.EPlatform.VIVO &&
                s.default.platform != s.EPlatform.OPPO &&
                s.default.platform != s.EPlatform.TikTok &&
                s.default.platform != s.EPlatform.WX) ||
            r.default.getInstance().showNavigateGroup(e, t, o, n);
        }),
        (e.prototype.showNavigateSettle = function(e, t, o) {
            (s.default.platform != s.EPlatform.test &&
                s.default.platform != s.EPlatform.VIVO &&
                s.default.platform != s.EPlatform.OPPO &&
                s.default.platform != s.EPlatform.TikTok &&
                s.default.platform != s.EPlatform.WX) ||
            r.default.getInstance().showNavigateSettle(e, t, o);
        }),
        (e.prototype.getNavigateBoxBannerFlag = function() {
            return (
                (s.default.platform == s.EPlatform.test ||
                    s.default.platform == s.EPlatform.OPPO ||
                    s.default.platform == s.EPlatform.VIVO) &&
                r.default.getInstance().getNavigateBoxBannerFlag()
            );
        }),
        (e.prototype.showNavigateBoxBanner = function() {
            (s.default.platform != s.EPlatform.test &&
                s.default.platform != s.EPlatform.OPPO &&
                s.default.platform != s.EPlatform.VIVO) ||
            (r.default.getInstance().getNavigateBoxBannerFlag() && r.default.getInstance().showNavigateBoxBanner());
        }),
        (e.prototype.getNavigateBoxPortalFlag = function() {
            return (
                (s.default.platform == s.EPlatform.test ||
                    s.default.platform == s.EPlatform.OPPO ||
                    s.default.platform == s.EPlatform.VIVO) &&
                r.default.getInstance().getNavigateBoxPortalFlag()
            );
        }),
        (e.prototype.showNavigateBoxPortal = function() {
            (s.default.platform != s.EPlatform.test &&
                s.default.platform != s.EPlatform.OPPO &&
                s.default.platform != s.EPlatform.VIVO) ||
            (r.default.getInstance().getNavigateBoxPortalFlag() && r.default.getInstance().showNavigateBoxPortal());
        }),
        (e.prototype.hideNavigateBoxPortal = function() {
            s.default.platform == s.EPlatform.VIVO && r.default.getInstance().hideNavigateBoxPortal();
        }),
        (e.prototype.hasAddDesktopFunc = function() {
            r.default.getInstance().hasAddDesktopFunc();
        }),
        (e.prototype.desktopFlag = function(e) {
            var t = this;
            s.default.platform != s.EPlatform.No_AD ?
                this.hasAddDesktopFunc &&
                r.default.getInstance().getAddDesktopFlag(function(o) {
                    t.AdLog("the desktopFlag is " + o), e(o ? n.Success : n.Fail);
                }) :
                e(n.Success);
        }),
        (e.prototype.addDeskTop = function(e) {
            var t = this;
            s.default.platform != s.EPlatform.No_AD ?
                (s.default.platform != s.EPlatform.test &&
                    s.default.platform != s.EPlatform.VIVO &&
                    s.default.platform != s.EPlatform.OPPO &&
                    s.default.platform != s.EPlatform.HUAWEI &&
                    s.default.platform != s.EPlatform.TikTok) ||
                r.default.getInstance().addDesktop(function(o) {
                    t.AdLog("the addDeskTop is " + o), e(o ? n.Success : n.Fail);
                }) :
                e(n.Success);
        }),
        (e.prototype.hideNavigateIcon = function() {
            (s.default.platform != s.EPlatform.VIVO &&
                s.default.platform != s.EPlatform.OPPO &&
                s.default.platform != s.EPlatform.TikTok &&
                s.default.platform != s.EPlatform.WX) ||
            r.default.getInstance().hideNavigateIcon();
        }),
        (e.prototype.hideNavigateGroup = function() {
            (s.default.platform != s.EPlatform.test &&
                s.default.platform != s.EPlatform.VIVO &&
                s.default.platform != s.EPlatform.OPPO &&
                s.default.platform != s.EPlatform.TikTok &&
                s.default.platform != s.EPlatform.WX) ||
            r.default.getInstance().hideNavigateGroup();
        }),
        (e.prototype.hideNavigateSettle = function() {
            (s.default.platform != s.EPlatform.test &&
                s.default.platform != s.EPlatform.VIVO &&
                s.default.platform != s.EPlatform.OPPO &&
                s.default.platform != s.EPlatform.TikTok &&
                s.default.platform != s.EPlatform.WX) ||
            r.default.getInstance().hideNavigateSettle();
        }),
        (e.prototype.hideNavigateBoxBanner = function() {
            (s.default.platform != s.EPlatform.test &&
                s.default.platform != s.EPlatform.OPPO &&
                s.default.platform != s.EPlatform.VIVO) ||
            r.default.getInstance().hideNavigateBoxBanner();
        }),
        (e.prototype.getGameTestVersion = function() {
            return s.default.platform != s.EPlatform.No_AD && r.default.getInstance().getGameTestVersion();
        }),
        (e.prototype.vibrateShort = function() {
            s.default.platform != s.EPlatform.test &&
                s.default.platform != s.EPlatform.No_AD &&
                r.default.getInstance().phoneVibrate("long");
        }),
        (e.prototype.InterSwitchLog = function() {}),
        (e.prototype.BannerSwitchLog = function() {}),
        (e.prototype.AdLog = function(e) {
            console.log("ad log广告日志:" + e, "=================");
        }),
        (e.prototype.getBigNativeAdFlag = function() {
            return s.default.platform == s.EPlatform.OPPO || s.default.platform == s.EPlatform.VIVO ?
                r.default.getInstance().getNativeAdFlag(1) :
                null;
        }),
        (e.prototype.getIconNativeAdFlag = function() {
            return s.default.platform == s.EPlatform.OPPO || s.default.platform == s.EPlatform.VIVO ?
                r.default.getInstance().getNativeAdFlag(2) :
                null;
        }),
        (e.prototype.getBigNativeInfo = function() {
            return this.getBigNativeAdFlag() ?
                s.default.platform == s.EPlatform.test || s.default.platform == s.EPlatform.OPPO ?
                r.default.getInstance().getNativeAdInfo(2) :
                s.default.platform == s.EPlatform.VIVO ?
                r.default.getInstance().getNativeAdInfo(1) :
                void 0 :
                null;
        }),
        (e.prototype.getIconNativeInfo = function() {
            return this.getIconNativeAdFlag() ?
                s.default.platform == s.EPlatform.test || s.default.platform == s.EPlatform.OPPO ?
                r.default.getInstance().getNativeAdInfo(2) :
                s.default.platform == s.EPlatform.VIVO ?
                r.default.getInstance().getNativeAdInfo(1) :
                void 0 :
                null;
        }),
        (e.prototype.reportNative = function(e) {
            r.default.getInstance().reportNativeAdShow(e);
        }),
        (e.prototype.nativeClick = function(e) {
            r.default.getInstance().reportNativeAdClick(e);
        }),
        (e.prototype.getNativeCloseErr = function() {
            return (
                (s.default.platform == s.EPlatform.VIVO || s.default.platform == s.EPlatform.OPPO) &&
                r.default.getInstance().getNativeCloseErr()
            );
        }),
        (e.prototype.StartRecorder = function(e) {
            return
            var t = this;
            void 0 === e && (e = 300),
                this.AdLog("开始录屏"),
                s.default.platform == s.EPlatform.TikTok &&
                (cc.sys.isBrowser ||
                    (tt.getGameRecorderManager().start({ duration: e, isMarkOpen: !1 }),
                        0 != this.IntervalTime && clearInterval(this.IntervalTime),
                        (this.RefreshTime = 299),
                        (this.IntervalTime = Number(
                            setInterval(function() {
                                t.isPause || t.RefreshTime--, t.RefreshTime <= 0 && t.StopRecorder();
                            }, 1e3)
                        ))));
        }),
        (e.prototype.StopRecorder = function(e) {
            return
            if (
                (void 0 === e && (e = 299),
                    this.AdLog("结束录屏"),
                    s.default.platform == s.EPlatform.TikTok && !cc.sys.isBrowser)
            ) {
                clearInterval(this.IntervalTime);
                var o = tt.getGameRecorderManager();
                o.onStop(function(n) {
                        o.clipVideo({
                                path: n.videoPath,
                                timeRange: [e, 0],
                                success: function(e) {
                                    console.log(e.videoPath);
                                },
                                fail: function(e) {
                                    console.error(e);
                                }
                            }),
                            console.log("结束录屏-录屏地址：" + n.videoPath),
                            (t.RECORDER_PATH = n.videoPath);
                    }),
                    o.stop();
            }
        }),
        (e.prototype.ShareVideo = function(e, o, n, a) {
            return
            if (s.default.platform == s.EPlatform.TikTok) {
                var i = t.RECORDER_PATH;
                this.AdLog("分享视频-录屏地址：" + i),
                    "" == i ?
                    (d.default.showNewToast("录屏失败，无法分享，请重新录屏"), cc.sys.isBrowser && n()) :
                    tt.shareAppMessage({
                        channel: "video",
                        title: e,
                        desc: e,
                        templateId: o,
                        extra: {
                            videoPath: i,
                            videoTopics: [e, "小游戏"],
                            hashtag_list: [e, "小游戏"],
                            video_title: ""
                        },
                        success: function() {
                            n && n();
                        },
                        fail: function(e) {
                            c.ObjectTool.forEachObject(e), a && a();
                        }
                    });
            }
        }),
        (e.prototype.PauseRecorder = function() {
            return
            this.AdLog("暂停录屏"),
                s.default.platform == s.EPlatform.TikTok &&
                (cc.sys.isBrowser || ((this.isPause = !0), tt.getGameRecorderManager().pause()));
        }),
        (e.prototype.ResumeRecorder = function() {
            return
            this.AdLog("继续录屏"),
                s.default.platform == s.EPlatform.TikTok &&
                (cc.sys.isBrowser || (this.isPause && ((this.isPause = !1), tt.getGameRecorderManager().resume())));
        }),
        (e.prototype.creatMoreGameButton = function(e, t) {
            if ((void 0 === t && (t = 720), s.default.platform == s.EPlatform.TikTok)) {
                if (this.DanceByteMoreGame) return this.DanceByteMoreGame;
                var o = e.convertToWorldSpaceAR(cc.v2()),
                    n = o.x / cc.winSize.width,
                    a = (cc.winSize.height - o.y) / cc.winSize.height,
                    i = n * tt.getSystemInfoSync().screenWidth,
                    r = a * tt.getSystemInfoSync().screenHeight,
                    l = cc.view.getFrameSize().width / t;
                (this.DanceByteMoreGame = tt.createMoreGamesButton({
                    type: "image",
                    image: "moreGame.png",
                    actionType: "box",
                    style: {
                        left: i,
                        top: r,
                        width: e.width * l,
                        height: e.height * l,
                        lineHeight: 40,
                        backgroundColor: "",
                        textColor: "",
                        textAlign: "center",
                        fontSize: 16,
                        borderRadius: 4,
                        borderWidth: 0,
                        borderColor: ""
                    },
                    appLaunchOptions: [{ appId: "ttXXXXXX", query: "foo=bar&baz=qux", extraData: {} }],
                    onNavigateToMiniGame: function(e) {
                        console.log("跳转其他小游戏", e);
                    }
                })),
                this.DanceByteMoreGame.onTap(function() {
                        console.log("点击更多游戏");
                    }),
                    this.hideMoreGameButton();
            }
        }),
        (e.prototype.showMoreGameButton = function() {
            this.DanceByteMoreGame && this.DanceByteMoreGame.show();
        }),
        (e.prototype.hideMoreGameButton = function() {
            this.DanceByteMoreGame && this.DanceByteMoreGame.hide();
        }),
        (e.RECORDER_PATH = ""),
        (t = __decorate([_], e))
    );
})();
o.default = u;